/*
 * table.cpp
 *
 *  Created on: Apr 18, 2012
 *      Author: songbo
 */
#include <fstream>
#include <vector>
#include <boost/algorithm/string.hpp>
#include "table.h"

namespace retail {

table::table(const std::string& TABLE_SCHEMA_FILE) {
	std::ifstream input(TABLE_SCHEMA_FILE.c_str());
	std::string  name, type;
	int length;
	double pecent;
	std::vector<std::string> vec;
	while(input>>name&&input>>type&&input>>length&&input>>pecent)
	{
		if(type=="INT4")
			type="int";
		else if(type =="DATS")
			type="date";
		else
			type="char";
		if(type=="char")
		{
			field f(type,length,pecent);
			fields.push_back(f);
		}
		else
		{
			field f(type,pecent);
			fields.push_back(f);
		}
	}


}

} /* namespace retail */
